<template>
    <div class="all">
        <div class="bread">首页>>用户管理>>用户列表</div>
        <div class="nav">
            <div>
                <el-button  type="primary"  plain @click="dialogVisible = true">添加用户</el-button> 
                <!-- <span>发布时间</span>
                <span>车型：    
                     <el-select v-model="value" placeholder="选择车型" style="width: 240px">
                       <el-option
                         v-for="item in options"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value"
                       />
                     </el-select>
                </span>
                <span>关键字<input></span>
                <span>搜索</span> -->
            </div>
        </div>
        <div class="content">
            <el-table :data="tableData" style="width: 100%">
              <el-table-column fixed prop="id" label="ID" width="260"/>
              <el-table-column prop="jiaose" label="用户名" width="260" />
              <el-table-column prop="miaoshu" label="真实姓名" width="260" />
              <el-table-column prop="beizhu" label="类型" width="260" />

              <el-table-column fixed="right" label="操作" width="120">
                <template #default>
                  <el-button link type="primary" size="small" @click="bianjiClick(tableData)"
                    >编辑</el-button>
                  <el-button link type="primary" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
        </div>
    </div>

    <!-- 添加记录对话框 -->
     <el-dialog
         v-model="dialogVisible"
         title="添加用户"
         width="400"
         :before-close="handleClose"
         style="text-align:center;padding-top: 30px;"
         center
       >
       <!-- 添加记录的表单内容 -->
      <el-form :model="form"  class="demo-form-inline">
          <el-form-item label="用户名" label-width="80px">
            <el-input v-model="form.zhanghao" />
          </el-form-item>     
          <el-form-item label="密码" label-width="80px">
            <el-input v-model="form.querenmima" />
          </el-form-item>  
          <!-- <el-form-item label="确认密码" label-width="80px">
            <el-input v-model="form.querenmima" />
          </el-form-item>   -->
          <!-- <el-form-item label="真实姓名" label-width="80px">
            <el-input v-model="form.mima" />
          </el-form-item> -->
          <!-- <el-form-item label="类型" label-width="80px">
            <el-input v-model="form.querenmima" />
          </el-form-item>     -->
        </el-form>

         <template #footer>
           <div class="dialog-footer">
             <el-button @click="dialogVisible = false">取消</el-button>
             <el-button type="primary" @click="dialogVisible = false">
               确认
             </el-button>
           </div>
         </template>
     </el-dialog>
       

    <!-- 编辑记录对话框 -->
     <el-dialog
         v-model="bianjiVisible"
         title="编辑其他记录"
         width="500"
         :before-close="handleClose"
         style="text-align:center;padding-top: 10px;"
       >
       <!-- 编辑记录的表单内容 -->
       <el-form :model="form1" label-width="auto" style="max-width: 800px;padding: 0px 40px 40px 40px;">
          <el-form-item label="帐号">
            <el-input v-model="form1.zhanghao" />
          </el-form-item>     
          <el-form-item label="密码">
            <el-input v-model="form1.mima" />
          </el-form-item>
          <el-form-item label="确认密码">
            <el-input v-model="form1.querenmima" />
          </el-form-item>    
          <el-form-item label="所属角色">
            <el-input v-model="form1.jiaose" />
          </el-form-item>
          <el-form-item label="真实名称">
            <el-input v-model="form1.xingming" />
          </el-form-item>


          <el-form-item label="描述">
            <el-input v-model="form1.zhuangtai" />
          </el-form-item>

        </el-form>


         <template #footer>
           <div class="dialog-footer">
             <el-button @click="bianjiVisible = false">取消</el-button>
             <el-button type="primary" @click="bianjiVisible = false">
               确认
             </el-button>
           </div>
         </template>
     </el-dialog>       
</template>

<script setup>
import { ref, reactive } from 'vue'

//添加记录对话框开关
const dialogVisible = ref(false)
//编辑记录对话框开关
const bianjiVisible = ref(false)

const value = ref('')


//车型选择
const options = [
    {
        value: '防撞车',
        label: '防撞车',
    },
    {
        value: '高空作业车',
        label: '高空作业车',
    },
    {
        value: '桥梁检测车',
        label: '桥梁检测车',
    },
    {
        value: '自行走',
        label: '自行走',
    }
]
//表格 标题和内容
const tableData = [
    {
        id: '01',
        jiaose: '超级管理员',
        miaoshu: '超级管理员',
        beizhu: '正常',
    },
    {
        id: '02',
        jiaose: '司机',
        miaoshu: '司机a',
        beizhu: '正常',
    },
    {
        id: '03',
        jiaose: '财务',
        miaoshu: '财务a',
        beizhu: '正常',
    }
]
// 添加记录的表单内容
const form = ref({
    zhanghao: '',
    mima: '',
    querenmima: '',
    jiaose: '',
    xingming: '',
    miaoshu: '',
})

// 添加记录的表单内容
const form1 = ref({
    zhanghao: '管理员001',
    mima: '',
    querenmima: '',
    jiaose: '超级管理员',
    xingming: 'admin',
    miaoshu: '192.12.18.1',
})

// 编辑车辆记录按钮
const bianjiClick = (data) => {
    bianjiVisible.value = true
    console.log(data)
    console.log('bianji')
}

</script>

<style lang="scss" scoped>
.all {
    background-color: #d6d6d6;
    height: 100%;
    overflow: hidden;
    padding-left: 10px;

    .bread {
        height: 30px;
        background-color: #fff;
        margin-bottom: 10px;
    }

    .nav {
        height: 40px;
        background-color: #fff;
        margin-bottom: 10px;
        padding: 5px;

        div {
            span {
                margin: 10px;
                line-height: 40px;
            }
        }
    }

    .content {
        background: #fff;
        height: 100%;
        padding: 5px;
        overflow: hidden;
    }
}
.demo-form-inline{
  padding: 10px 30px;
}
.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}
</style>